package com.mobvel.zxstdzgl.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.Log;

public class IndexHelper {

	public static List<String> getAssetData(Resources resources, int cateId) {
		try {
			AssetManager localAssetManager = resources.getAssets();
			
			String str = null;
			if(0 == cateId) {
				str = "index.txt";
			}else {
				str = "" + cateId + "index.txt";
			}
			
			InputStream input = localAssetManager.open(str);

			// 方法一：一次性读取
			int length = input.available();
			byte[] buffer = new byte[length];
			input.read(buffer);
			String mContent = new String(buffer, "UTF-8");
			
			ArrayList<String> artList = new ArrayList<String>();
			String [] arts = mContent.trim().split("\r\n");
			Log.e("xx", "arts size = "+arts.length);
			for(int i = 0; i < arts.length; i++) {
				artList.add(arts[i]);
			}
			
			return artList;
		} catch (IOException localIOException) {
			//
		}
		
		return null;
	}

	
}
